home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / tbasmhlp.arc / SOURCE.ARC / XQPRINT.ASM < prev   
Encoding:
Assembly Source File  |  1987-07-24  |  2.4 KB  |  97 lines

  1. ;FILE    :XQPRINT
  2. ;USEAGE    :call xqprint(a$,x%,y%,attr%,page%)
  3.  
  4. xqprint    segment
  5. assume    cs:xqprint
  6.     push    bp        ;Nothing new
  7.     mov    bp,sp        ;now we can get parameters
  8.     push    ds        ;save it too!
  9.  
  10.                 ;First let's get our dataseg to the string's data
  11.     les    di,[bp+016h]    ;Get string descripters seg/address
  12.     mov    dx,ds:[0]
  13.     push    dx
  14.     pop    ds
  15.     mov    cx,es:[di]    ;Length of string
  16.     and     cx,0efffh    ;Mask off upper bit, it's reserved.
  17.     jz    xqpend        ;Null string? Just exit then
  18.     mov    si,es:[di+2]    ;Offset of string
  19.  
  20.     les    di,[bp+0ah]    ;Let's get attr and push it
  21.     mov    ax,es:[di]
  22.     push    ax        ;Push color/attribute
  23.  
  24.     les    di,[bp+06h]    ;Now let's get output page.
  25.     mov    ax,es:[di]
  26.     push    ax        ;Okay, put in on stack too.
  27.  
  28.     les    di,[bp+0eh]    ;X pos
  29.     mov    ax,es:[di]    ;okay, got x pos now
  30.     push    ax        ;save x pos on stack
  31.  
  32.     les    di,[bp+12h]    ;Y pos address
  33.     mov    ax,es:[di]    ;ax now has ypos
  34.     dec    ax        ;ypos-1
  35.  
  36.     mov    bx,040h        ;Let's find screen width
  37.     mov    es,bx        ;Be nice, don't assume 80 chars.
  38.     mul    word ptr es:[004ah] ;this holds display width in chars
  39.     pop    di        ;xposition
  40.     dec    di
  41.     add    di,ax
  42.     shl    di,1        ;multiply offset by 2 (2 bytes/char)
  43.     mov    dx,es:[0063h]    ;Let's find out where status port is
  44.     add    dx,6        ;okay.. we want 3d6
  45.  
  46.     mov    ax,0b000h    ;Monochrome, now are we color?
  47.     cld            ;Clear direction flag.
  48.  
  49.     mov    bx,es:[010h]    ;Let's see
  50.     and    bx,030h        ;now should hold a 20
  51.     cmp    bx,030h        ;Are we color?
  52.     jz    monocm        ;Nope, we'v got address. it's monochrome
  53.  
  54.     mov    ah,0b8h        ;We're color! so set hi addr.
  55.     pop    bx        ;Page to write on.
  56.     or    bx,bx        ;0?
  57.     jz    page0        ;jump if we iz.
  58. pagelop:add    di,1000h    ;go forward a page
  59.     dec    bx
  60.     jnz    pagelop        ;branch if we have more pages to go
  61. page0:    mov    es,ax        ;set ES to display page
  62.     pop    bx        ;Color they want/Attribute
  63.     mov    bh,bl        ;Put color up high
  64.  
  65. ;This is main output loop
  66. mainout:lodsb            ;get a char into accumulator from SI
  67.     mov    bl,al        ;put char in bl
  68.     cli            ;turn off irqs while we wait for horz go.
  69.  
  70. notyet:    in    al,dx        ;from video board (this avoids snow)
  71.     shr    al,1
  72.     jb    notyet
  73.  
  74. notyet2:in    al,dx        ;Okay, now let's make sure it's ready
  75.     shr    al,1
  76.     jnb    notyet2
  77.  
  78.     mov    ax,bx        ;char,attribute
  79.     stosw            ;Okay write out char    
  80.     sti            ;Re-enable irq
  81.     loop    mainout
  82.     jmp    xqpend        ;goto end
  83.  
  84. monocm:    mov    es,ax
  85.     pop    bx        ;Page is pushed on stack, we don't use it.
  86.     pop    ax    
  87.     mov    ah,al        ;Move color to hi part of byte
  88. monoout:lodsb            ;get char in al
  89.     stosw            ;out al+ah
  90.     loop    monoout
  91.  
  92. xqpend:    pop    ds
  93.     pop    bp
  94. xqprint    ends
  95.     end
  96.  
  97.